from flask import Blueprint, request
from ..controllers.complaint import (
    create_complaint,
    get_complaints,
    get_complaint,
    update_complaint,
    delete_complaint,
    upvote_complaint,
    downvote_complaint
)

# 创建投诉相关的蓝图
complaint_bp = Blueprint('complaint', __name__)

# 注册路由
# 注意：根据要求，这里不使用JWT认证

# 创建投诉记录
@complaint_bp.route('/complaints/add', methods=['POST'])
def route_create_complaint():
    return create_complaint()

# 获取投诉列表
@complaint_bp.route('/complaints/list', methods=['GET'])
def route_get_complaints():
    data = request.args.to_dict() or {}
    return get_complaints(data)

# 获取单个投诉记录
@complaint_bp.route('/complaints/get', methods=['GET'])
def route_get_complaint():
    return get_complaint()

# 更新投诉记录
@complaint_bp.route('/complaints/update', methods=['POST'])
def route_update_complaint():
    return update_complaint()

# 删除投诉记录
@complaint_bp.route('/complaints/delete', methods=['POST'])
def route_delete_complaint():
    return delete_complaint()

# 点赞投诉
@complaint_bp.route('/complaints/upvote', methods=['POST'])
def route_upvote_complaint():
    return upvote_complaint()

# 点踩投诉
@complaint_bp.route('/complaints/downvote', methods=['POST'])
def route_downvote_complaint():
    return downvote_complaint()